﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Identity;

namespace BackendAdminApp.Host.Controllers
{
    [Authorize]
    [ApiController]
    [Route("api/identity")]
    public class IdentityController : AbpController
    {
        private readonly IIdentityUserAppService _identityUserAppService;
        private readonly IIdentityRoleAppService _identityRoleAppService;

        public IdentityController(IIdentityUserAppService identityUserAppService, IIdentityRoleAppService identityRoleAppService)
        {
            _identityUserAppService = identityUserAppService;
            _identityRoleAppService = identityRoleAppService;
        }

        [HttpGet]
        [Route("users")]
        public Task<PagedResultDto<IdentityUserDto>> GetIdentityUsersAsync([FromQuery] GetIdentityUsersInput input)
        {
            return _identityUserAppService.GetListAsync(input);
        }

        [HttpGet]
        [Route("roles")]
        public Task<PagedResultDto<IdentityRoleDto>> GetIdentityRolesAsync([FromQuery] GetIdentityRolesInput input)
        {
            return _identityRoleAppService.GetListAsync(input);
        }
    }
}
